<template>
	<view class="mainpadding2">
		<view class="flexcolumn" v-if="!list.data.length">
			<view class="placeholderimage"></view>
			<view class="margin_top xiaohui">暂无数据！</view>
		</view>
		<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id" @click="jumpurl('/pages_forum/luntanxq?id=',item.id)">
			<view class="flexleft">
				<image :src="item.user.avatar" mode="" class="listheadplimg"></image>
				<view class="flexcolumnbet" style="height: 70rpx;">
					<view class="xiaohei margin_left1">{{item.user.nickname}}</view>
					<view class="xiaohui margin_left1">{{item.createtime_text}}</view>
				</view>
			</view>
			<view class="hei_text bold main_size margin_top2 lianghang">{{item.title}}</view>
			<view class="xiaohui margin_top2 lianghang">{{item.description}}</view>
			<view class="flexleft">
				<view class="itemimgBox flexcenter margin_top" v-for="(ite,inde) in item.images_arr" :key="inde">
					<image class="listleftimg radius" :src="ite" mode=""></image>
				</view>
			</view>
		</view>
		<liu-drag-button @clickBtn="replactforum()">
			<image src="@/static/image/system/add.png" class="replactforum" mode=""></image>
		</liu-drag-button>
		<u-modal :show="show" title="禁止发布" @confirm="show=false">
			<view class="slot-content">
				<view class="mainpadding_top">
					<view class="textcenter hei_text main_size bold">
						<text>由于您违反平台规定，先对您处以禁止发布</text>
						<text class="hong_text">60小时</text>
						<text>处罚！</text>
					</view>
					<view class="margin_top hong_text bold main_size flexcenter">
						<view class="">处罚倒计时</view>      
						<u-count-down :time="60*60*60*1000" class="hong_text bold main_size" format="HH:mm:ss"></u-count-down>
					</view>
				</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show:false,
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init(isPage, page) { 
				let _this = this;
				httpRequest.request('/api/community/getlist', 'GET', {
					page: page || 1,
					limit: _this.limit,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom(){
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumpurl(url, id) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: url + id
				})
			},
			replactforum(){
				// this.show = true
				// return
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url:'/pages_forum/fabult'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.replactforum {
		width: 92rpx;
		height: 92rpx;
	}
	/deep/.u-count-down__text{
		color: #ff0000;
	}

	// 注意，引入悬浮插件必须填写此样式否则会有默认样式存在
	/deep/.movable-view {
		background: none !important;
		box-shadow: none !important;
	}
</style>